// owner-app/pages/my-dwell/index.js
import { handlerGobackClick, onlyChangeRouter } from "../../../utils/util";
const app = getApp();
import { Houses } from "../../../models/houses";
const house = new Houses();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    baseImgUrl: getApp().globalImgUrl.config.baseImgUrl,
    scrollH: "auto",
    houseList: [],
    pageNum: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      pageNum: 1,
      houseList: [],
    });
    this.getData();
  },
  getData() {
    house.list(this.data.pageNum, 10).then((res) => {
      let houseList = this.data.houseList.concat(res.result.records || []);
      this.setData({
        houseList,
      });
    });
  },
  handlerGobackClick,
  onlyChangeRouter,
  addHouse() {
    wx.navigateTo({
      url: "../addHouse/index",
    });
  },
  scrollBottom(e) {
    this.setData({
      pageNum: this.data.pageNum + 1,
    });
    this.getData();
  },
});
